package com.xiaour.spring.boot.page;

import static io.grpc.MethodDescriptor.generateFullMethodName;
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
import static io.grpc.stub.ClientCalls.futureUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;

/**
 * <pre>
 * 定义服务
 * </pre>
 */
@javax.annotation.Generated(
    value = "by gRPC proto compiler (version 1.32.1)",
    comments = "Source: page.proto")
public final class PaginationServiceGrpc {

  private PaginationServiceGrpc() {}

  public static final String SERVICE_NAME = "pagination.PaginationService";

  // Static method descriptors that strictly reflect the proto.
  private static volatile io.grpc.MethodDescriptor<PageProto.PageRequest,
      PageProto.PageResponse> getGetItemsMethod;

  @io.grpc.stub.annotations.RpcMethod(
      fullMethodName = SERVICE_NAME + '/' + "GetItems",
      requestType = PageProto.PageRequest.class,
      responseType = PageProto.PageResponse.class,
      methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
  public static io.grpc.MethodDescriptor<PageProto.PageRequest,
      PageProto.PageResponse> getGetItemsMethod() {
    io.grpc.MethodDescriptor<PageProto.PageRequest, PageProto.PageResponse> getGetItemsMethod;
    if ((getGetItemsMethod = PaginationServiceGrpc.getGetItemsMethod) == null) {
      synchronized (PaginationServiceGrpc.class) {
        if ((getGetItemsMethod = PaginationServiceGrpc.getGetItemsMethod) == null) {
          PaginationServiceGrpc.getGetItemsMethod = getGetItemsMethod =
              io.grpc.MethodDescriptor.<PageProto.PageRequest, PageProto.PageResponse>newBuilder()
              .setType(io.grpc.MethodDescriptor.MethodType.UNARY)
              .setFullMethodName(generateFullMethodName(SERVICE_NAME, "GetItems"))
              .setSampledToLocalTracing(true)
              .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
                  PageProto.PageRequest.getDefaultInstance()))
              .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
                  PageProto.PageResponse.getDefaultInstance()))
              .setSchemaDescriptor(new PaginationServiceMethodDescriptorSupplier("GetItems"))
              .build();
        }
      }
    }
    return getGetItemsMethod;
  }

  /**
   * Creates a new async stub that supports all call types for the service
   */
  public static PaginationServiceStub newStub(io.grpc.Channel channel) {
    io.grpc.stub.AbstractStub.StubFactory<PaginationServiceStub> factory =
      new io.grpc.stub.AbstractStub.StubFactory<PaginationServiceStub>() {
        @Override
        public PaginationServiceStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
          return new PaginationServiceStub(channel, callOptions);
        }
      };
    return PaginationServiceStub.newStub(factory, channel);
  }

  /**
   * Creates a new blocking-style stub that supports unary and streaming output calls on the service
   */
  public static PaginationServiceBlockingStub newBlockingStub(
      io.grpc.Channel channel) {
    io.grpc.stub.AbstractStub.StubFactory<PaginationServiceBlockingStub> factory =
      new io.grpc.stub.AbstractStub.StubFactory<PaginationServiceBlockingStub>() {
        @Override
        public PaginationServiceBlockingStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
          return new PaginationServiceBlockingStub(channel, callOptions);
        }
      };
    return PaginationServiceBlockingStub.newStub(factory, channel);
  }

  /**
   * Creates a new ListenableFuture-style stub that supports unary calls on the service
   */
  public static PaginationServiceFutureStub newFutureStub(
      io.grpc.Channel channel) {
    io.grpc.stub.AbstractStub.StubFactory<PaginationServiceFutureStub> factory =
      new io.grpc.stub.AbstractStub.StubFactory<PaginationServiceFutureStub>() {
        @Override
        public PaginationServiceFutureStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
          return new PaginationServiceFutureStub(channel, callOptions);
        }
      };
    return PaginationServiceFutureStub.newStub(factory, channel);
  }

  /**
   * <pre>
   * 定义服务
   * </pre>
   */
  public static abstract class PaginationServiceImplBase implements io.grpc.BindableService {

    /**
     */
    public void getItems(PageProto.PageRequest request,
                         io.grpc.stub.StreamObserver<PageProto.PageResponse> responseObserver) {
      asyncUnimplementedUnaryCall(getGetItemsMethod(), responseObserver);
    }

    @Override public final io.grpc.ServerServiceDefinition bindService() {
      return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
          .addMethod(
            getGetItemsMethod(),
            asyncUnaryCall(
              new MethodHandlers<
                PageProto.PageRequest,
                PageProto.PageResponse>(
                  this, METHODID_GET_ITEMS)))
          .build();
    }
  }

  /**
   * <pre>
   * 定义服务
   * </pre>
   */
  public static final class PaginationServiceStub extends io.grpc.stub.AbstractAsyncStub<PaginationServiceStub> {
    private PaginationServiceStub(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @Override
    protected PaginationServiceStub build(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      return new PaginationServiceStub(channel, callOptions);
    }

    /**
     */
    public void getItems(PageProto.PageRequest request,
                         io.grpc.stub.StreamObserver<PageProto.PageResponse> responseObserver) {
      asyncUnaryCall(
          getChannel().newCall(getGetItemsMethod(), getCallOptions()), request, responseObserver);
    }
  }

  /**
   * <pre>
   * 定义服务
   * </pre>
   */
  public static final class PaginationServiceBlockingStub extends io.grpc.stub.AbstractBlockingStub<PaginationServiceBlockingStub> {
    private PaginationServiceBlockingStub(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @Override
    protected PaginationServiceBlockingStub build(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      return new PaginationServiceBlockingStub(channel, callOptions);
    }

    /**
     */
    public PageProto.PageResponse getItems(PageProto.PageRequest request) {
      return blockingUnaryCall(
          getChannel(), getGetItemsMethod(), getCallOptions(), request);
    }
  }

  /**
   * <pre>
   * 定义服务
   * </pre>
   */
  public static final class PaginationServiceFutureStub extends io.grpc.stub.AbstractFutureStub<PaginationServiceFutureStub> {
    private PaginationServiceFutureStub(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @Override
    protected PaginationServiceFutureStub build(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      return new PaginationServiceFutureStub(channel, callOptions);
    }

    /**
     */
    public com.google.common.util.concurrent.ListenableFuture<PageProto.PageResponse> getItems(
        PageProto.PageRequest request) {
      return futureUnaryCall(
          getChannel().newCall(getGetItemsMethod(), getCallOptions()), request);
    }
  }

  private static final int METHODID_GET_ITEMS = 0;

  private static final class MethodHandlers<Req, Resp> implements
      io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
    private final PaginationServiceImplBase serviceImpl;
    private final int methodId;

    MethodHandlers(PaginationServiceImplBase serviceImpl, int methodId) {
      this.serviceImpl = serviceImpl;
      this.methodId = methodId;
    }

    @Override
    @SuppressWarnings("unchecked")
    public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
      switch (methodId) {
        case METHODID_GET_ITEMS:
          serviceImpl.getItems((PageProto.PageRequest) request,
              (io.grpc.stub.StreamObserver<PageProto.PageResponse>) responseObserver);
          break;
        default:
          throw new AssertionError();
      }
    }

    @Override
    @SuppressWarnings("unchecked")
    public io.grpc.stub.StreamObserver<Req> invoke(
        io.grpc.stub.StreamObserver<Resp> responseObserver) {
      switch (methodId) {
        default:
          throw new AssertionError();
      }
    }
  }

  private static abstract class PaginationServiceBaseDescriptorSupplier
      implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier {
    PaginationServiceBaseDescriptorSupplier() {}

    @Override
    public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
      return PageProto.getDescriptor();
    }

    @Override
    public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() {
      return getFileDescriptor().findServiceByName("PaginationService");
    }
  }

  private static final class PaginationServiceFileDescriptorSupplier
      extends PaginationServiceBaseDescriptorSupplier {
    PaginationServiceFileDescriptorSupplier() {}
  }

  private static final class PaginationServiceMethodDescriptorSupplier
      extends PaginationServiceBaseDescriptorSupplier
      implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
    private final String methodName;

    PaginationServiceMethodDescriptorSupplier(String methodName) {
      this.methodName = methodName;
    }

    @Override
    public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() {
      return getServiceDescriptor().findMethodByName(methodName);
    }
  }

  private static volatile io.grpc.ServiceDescriptor serviceDescriptor;

  public static io.grpc.ServiceDescriptor getServiceDescriptor() {
    io.grpc.ServiceDescriptor result = serviceDescriptor;
    if (result == null) {
      synchronized (PaginationServiceGrpc.class) {
        result = serviceDescriptor;
        if (result == null) {
          serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
              .setSchemaDescriptor(new PaginationServiceFileDescriptorSupplier())
              .addMethod(getGetItemsMethod())
              .build();
        }
      }
    }
    return result;
  }
}
